<template>
	<view>
		<jinEdit :html="detail" placeholder="请输入内容" fileKeyName="image" :header="header" @editOk="editOk" :uploadFileUrl="action"></jinEdit>
	</view>
</template>

<script>
	import jinEdit from '@/components/jin-edit/jin-edit.vue';
	import api from '@/common/uploadApi'
	export default {
		data() {
			return {
				action:api.foodUploadImage,
				header: {
					"Authorization": 'Bearer ' + uni.getStorageSync('token')
				},
				id:'',
				detail:''
			}
		},
		components: {
			jinEdit
		},
		onLoad(option) {
			if(option.id){
				this.id = option.id;
				this.getGoodsDetail();
			}
		},
		methods: {
			getGoodsDetail(){
				this.$u.offlineApi.foodDetails({
					id: this.id
				}).then(res => {
					if (res.code == 0) {
						this.detail = res.data.details;
					}
				})
			},
			// 点击发布
			editOk(data) {
				let pages = getCurrentPages();
				let currPage = pages[pages.length-2];
				currPage.$vm.form.details = data.html;
				uni.navigateBack();
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
